<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Oboe: oboe::AudioStreamDataCallback Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Oboe
   &#160;<span id="projectnumber">1.5</span>
   </div>
   <div id="projectbrief">A library for creating real-time audio apps on Android</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceoboe.html">oboe</a></li><li class="navelem"><a class="el" href="classoboe_1_1_audio_stream_data_callback.html">AudioStreamDataCallback</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classoboe_1_1_audio_stream_data_callback-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">oboe::AudioStreamDataCallback Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="_audio_stream_callback_8h_source.html">AudioStreamCallback.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for oboe::AudioStreamDataCallback:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classoboe_1_1_audio_stream_data_callback.png" usemap="#oboe::AudioStreamDataCallback_map" alt=""/>
  <map id="oboe::AudioStreamDataCallback_map" name="oboe::AudioStreamDataCallback_map">
<area href="classoboe_1_1_audio_stream_callback.html" alt="oboe::AudioStreamCallback" shape="rect" coords="0,56,193,80"/>
<area href="classoboe_1_1_stabilized_callback.html" alt="oboe::StabilizedCallback" shape="rect" coords="0,112,193,136"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad8a3a9f609df5fd3a5d885cbe1b2204d"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_audio_stream_data_callback.html#ad8a3a9f609df5fd3a5d885cbe1b2204d">onAudioReady</a> (<a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *audioStream, void *audioData, int32_t numFrames)=0</td></tr>
<tr class="separator:ad8a3a9f609df5fd3a5d885cbe1b2204d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classoboe_1_1_audio_stream_data_callback.html">AudioStreamDataCallback</a> defines a callback interface for moving data to/from an audio stream using <code>onAudioReady</code> 2) being alerted when a stream has an error using <code>onError*</code> methods</p>
<p>It is used with <a class="el" href="classoboe_1_1_audio_stream_builder.html#acad307720e0f370267b4e2f9a626ae70">AudioStreamBuilder::setDataCallback()</a>. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="ad8a3a9f609df5fd3a5d885cbe1b2204d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad8a3a9f609df5fd3a5d885cbe1b2204d">&#9670;&nbsp;</a></span>onAudioReady()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual <a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a> oboe::AudioStreamDataCallback::onAudioReady </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *&#160;</td>
          <td class="paramname"><em>audioStream</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>audioData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>numFrames</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>A buffer is ready for processing.</p>
<p>For an output stream, this function should render and write numFrames of data in the stream's current data format to the audioData buffer.</p>
<p>For an input stream, this function should read and process numFrames of data from the audioData buffer.</p>
<p>The audio data is passed through the buffer. So do NOT call read() or write() on the stream that is making the callback.</p>
<p>Note that numFrames can vary unless <a class="el" href="classoboe_1_1_audio_stream_builder.html#a3f397821f61eabaeedaf31064c859a54">AudioStreamBuilder::setFramesPerCallback()</a> is called.</p>
<p>Also note that this callback function should be considered a "real-time" function. It must not do anything that could cause an unbounded delay because that can cause the audio to glitch or pop.</p>
<p>These are things the function should NOT do: </p><ul>
<li>
allocate memory using, for example, malloc() or new </li>
<li>
any file operations such as opening, closing, reading or writing </li>
<li>
any network operations such as streaming </li>
<li>
use any mutexes or other synchronization primitives </li>
<li>
sleep </li>
<li>
oboeStream-&gt;stop(), pause(), flush() or close() </li>
<li>
oboeStream-&gt;read() </li>
<li>
oboeStream-&gt;write() </li>
</ul>
<p>The following are OK to call from the data callback: </p><ul>
<li>
oboeStream-&gt;get*() </li>
<li>
<a class="el" href="namespaceoboe.html#af65aaea3c5d82eee6906664d61c094b3">oboe::convertToText()</a> </li>
<li>
oboeStream-&gt;setBufferSizeInFrames() </li>
</ul>
<p>If you need to move data, eg. MIDI commands, in or out of the callback function then we recommend the use of non-blocking techniques such as an atomic FIFO.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">audioStream</td><td>pointer to the associated stream </td></tr>
    <tr><td class="paramname">audioData</td><td>buffer containing input data or a place to put output data </td></tr>
    <tr><td class="paramname">numFrames</td><td>number of frames to be processed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>DataCallbackResult::Continue or DataCallbackResult::Stop </dd></dl>

<p>Implemented in <a class="el" href="classoboe_1_1_stabilized_callback.html#ad447e12ebf732cf151655c1fbaf58a49">oboe::StabilizedCallback</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/oboe/<a class="el" href="_audio_stream_callback_8h_source.html">AudioStreamCallback.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
